<!--管理员添加学生缴费记录-->
<link rel="stylesheet" href="./css/jiaofei.css">

<div class="modal-dialog modal fade" id="submit1">
	<div class="modal-content">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal">&times;</button>
			<h4>提示</h4>
		</div>
		<div class="modal-body">
			<p>提交成功！</p>
		</div>
		<div class="modal-footer">
			<button type="button" class="btn btn-primary" class="close" data-dismiss="modal">确认</button>
			<button type="button" class="btn btn-default" class="close" data-dismiss="modal">取消</button>
		</div>
	</div>
</div>
<div class="modal-dialog modal fade" id="shangchuan">
	<div class="modal-content">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal">&times;</button>
			<h4>提示</h4>
		</div>
		<div class="modal-body">
			<p>上传成功！</p>
		</div>
		<div class="modal-footer">
			<button type="button" class="btn btn-primary" class="close" data-dismiss="modal">确认</button>
			<button type="button" class="btn btn-default" class="close" data-dismiss="modal">取消</button>
		</div>
	</div>
</div>
<div class="modal-dialog modal fade" id="shibai">
	<div class="modal-content">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal">&times;</button>
			<h4>提示</h4>
		</div>
		<div class="modal-body">
			<p>提交失败！</p>
		</div>
		<div class="modal-footer">
			<button type="button" class="btn btn-primary" class="close" data-dismiss="modal">确认</button>
			<button type="button" class="btn btn-default" class="close" data-dismiss="modal">取消</button>
		</div>
	</div>
</div>
<div class="modal-dialog modal fade" id="shangchuan1">
	<div class="modal-content">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal">&times;</button>
			<h4>提示</h4>
		</div>
		<div class="modal-body">
			<p>上传失败！</p>
		</div>
		<div class="modal-footer">
			<button type="button" class="btn btn-primary" class="close" data-dismiss="modal">确认</button>
			<button type="button" class="btn btn-default" class="close" data-dismiss="modal">取消</button>
		</div>
	</div>
</div>

<h3 class="text-center">添加缴费记录</h3>
<div class="input-group margintop">
	<span class="input-group-addon" id="zhuanye">专业</span>
	<select id="zhuanye1">

	</select>
</div>
<div class="input-group  margintop">
	<span class="input-group-addon" id="xuehao">学号</span>
	<input type="text" id="xuehao1" class="form-control" placeholder="请输入学生学号" aria-describedby="sizing-addon1">
</div>
<div class="input-group margintop">
	<span class="input-group-addon" id="yescost">已缴学费</span>
	<input type="text" id="yescost1" class="form-control" placeholder="请输入已缴学费" aria-describedby="sizing-addon1">
</div>

<button type="button" class="btn btn-primary" id="submit">提交记录</button>
<button id="daoru" type="button" class="btn btn-primary">批量导入记录</button>

<script>
	$('#submit1').on('hidden.bs.modal', function() {
		$('.center').html('');
		$('.center').load('./jiaofei.html');
	})

	$.ajax({
		xhrFields: {
			withCredentials: true
		},
		type: 'get',
		url: getFullURL("admin/get-schoolings"),
		data: {},
		dataType: 'json',
		success: function(data) {
			if(data.status == 0) {
				console.log(data);
				$.each(data.list, function(i, n) {
					var str = `
						<option value="` + n.slid + `">` + n.specialty + `</option>
					`;
					$('#zhuanye1').append(str);
				})
			}
		},
		error: function(err) {
			alert("请求异常，请重新登录！", function() {
				$(location).attr('href', './login.html');
			})
		}
	})

	$('#submit').click(function() {

		$.ajax({
			xhrFields: {
				withCredentials: true
			},
			type: 'POST',
			url: getFullURL("admin/add-payment"),
			data: {
				slid: $("#zhuanye1").val(),
				sno: $('#xuehao1').val(),
				cost: $('#yescost1').val()
			},
			dataType: 'json',
			success: function(data) {
				if(data.status == 0) {
					$('#submit1').modal({
						keyboard: true,
						show: true
					})
				} else if(data.status == -1) {
					$('#shibai').modal({
						keyboard: true,
						show: true
					})
				}
			},
			error: function(err) {
				alert("请求异常，请重新登录！", function() {
					$(location).attr('href', './login.html');
				})
			}
		})
	})
</script>